home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / MACVOGL- / EXAMPLES / SIMPLE.C < prev    next >
C/C++ Source or Header  |  1992-07-19  |  1KB  |  78 lines

  1. #include <stdio.h>
  2.  
  3. #ifdef SGI
  4. #include "gl.h"
  5. #include "device.h"
  6. #else
  7. #include "vogl.h"
  8. #include "vodevice.h"
  9. #endif
  10.  
  11. /*
  12.  * A program showing basic line drawing, hardware text and (if applicable)
  13.  * colour. We set the coordinate system to -1.0 to 1.0 in X and Y.
  14.  */
  15. main(ac, av)
  16.     int    ac;
  17.     char    **av;
  18. {
  19.     char    *p, tmp[2];
  20.     float    cw, ch;
  21.     short    val;
  22.  
  23.     prefposition(100L, 700L, 100L, 500L);
  24.     winopen("simple");
  25.  
  26.     if (ac == 2)
  27.         font(atoi(av[1]));    /* change font to the argument */
  28.  
  29.     color(BLACK);        /* set current color */
  30.     clear();        /* clear screen to current color */
  31.  
  32.     ortho2(-1.0, 1.0, -1.0, 1.0);    /* set bounds for drawing */
  33.  
  34.     color(GREEN);
  35.             /* 2 d move to start where we want drawstr to start */
  36.     cmov2(-0.9, 0.9);
  37.  
  38.     charstr("A Simple Example");    /* draw string in current color */
  39.  
  40.     /*
  41.      * the next four lines draw the x 
  42.      */
  43.     move2(0.0, 0.0);
  44.     draw2(0.76, 0.76);
  45.     move2(0.0, 0.76);
  46.     draw2(0.76, 0.0);
  47.  
  48.     cmov2(0.0, 0.5);
  49.     charstr("x done");
  50.     charstr("next sentence");
  51.  
  52.     cmov(0.0, 0.1, -1.0);
  53.     /*
  54.      * One character at a time...
  55.      */
  56.     tmp[1] = '\0';
  57.     for (p = "hello world"; *p != NULL; p++) {
  58.         tmp[0] = *p;
  59.         charstr(tmp);     
  60.     }
  61.  
  62.     /*
  63.      * the next five lines draw the square
  64.      */
  65.     move2(0.,0.);
  66.     draw2(.76,0.);
  67.     draw2(.76,.76);
  68.     draw2(0.,.76);
  69.     draw2(0.,0.);
  70.  
  71.     qdevice(KEYBD);        /* enable the keyboard */
  72.     unqdevice(INPUTCHANGE);
  73.  
  74.     qread(&val);        /* wait for some input */
  75.  
  76.     gexit();        /* set the screen back to its original state */
  77. }
  78.